<template>
    <div>
        <div class="header-title">
            <span @click="$router.go(-1)" class="mint-toast-icon mintui mintui-back"></span>
            <span>修改密码</span>
            <span></span>
        </div>
        <div class="num-list">
            <div class="input-area">
                <span>原密码</span>
                <input
                    v-model="password.originalPassword"
                    style="text-align:right"
                    type="text"
                    name
                    id
                    placeholder="请输入原密码"
                />
            </div>
            <div class="input-area">
                <span>新密码</span>
                <input
                    v-model="password.newPassword"
                    style="text-align:right"
                    type="text"
                    name
                    id
                    placeholder="请输入新密码"
                />
            </div>
            <div class="input-area">
                <span>确认密码</span>
                <input
                    v-model="password.confirmPassword"
                    style="text-align:right"
                    type="text"
                    name
                    id
                    placeholder="请确认新密码"
                />
            </div>
            <p class="msg-one">
                <span
                    @click="$router.push({name:'safetyVerificationCode',query:{urlAddress:'changeSetPassword',titleType:'1'}})"
                >忘记原密码？</span>
            </p>
            <mt-button size="normal" class="submit-btn" @click="modifyPassword">确定</mt-button>
        </div>
    </div>
</template>
<script>
import { Toast } from "mint-ui";
export default {
    data() {
        return {
            password: {
                originalPassword: "",
                newPassword: "",
                confirmPassword: "",
                token: JSON.parse(this.$store.state.userMsg).token,
                type: "0",
                passwordType: "0"
            }
        };
    },
    methods: {
        modifyPassword() {
            if (
                this.password.originalPassword == "" ||
                this.password.newPassword == "" ||
                this.password.confirmPassword == ""
            ) {
                Toast({ message: "请输入完整的密码" });
                return false;
            }
            this.$axios
                .post(this.address.updatePassword, this.password)
                .then(res => {
                    console.log(res.data);
                    if (res.data.code == 200) {
                        Toast({ message: "密码修改成功" });
                        this.$router.push({ name: "login" });
                    } else {
                        Toast({ message: res.data.msg });
                    }
                });
        }
    }
};
</script>
<style lang="less" scoped>
.num-list {
    padding: 15px;
    box-sizing: border-box;
}
</style>
